import java.util.PriorityQueue;
import java.util.Queue;
import java.util.Scanner;

/**
 * @Title: java里面的优先队列test
 * @Author 贾金博
 * @Package PACKAGE_NAME
 * @Date 2024/3/14 22:04
 * @description:
 */
public class java里面的优先队列test {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Queue<test> q = new PriorityQueue();
        q.add(new test(1, 1, "1"));
        q.add(new test(2, 1, "1"));
        q.add(new test(4, 1, "2"));
        q.add(new test(3, 1, "2"));


        while(!q.isEmpty()) {
            System.out.println(q.poll());
        }
        
    }
}

class test implements Comparable<test>{
    private int x;
    private int y;
    private String z;

    public test() {
    }

    public test(int x, int y, String z) {
        this.x = x;
        this.y = y;
        this.z = z;
    }

    /**
     * 获取
     * @return x
     */
    public int getX() {
        return x;
    }

    /**
     * 设置
     * @param x
     */
    public void setX(int x) {
        this.x = x;
    }

    /**
     * 获取
     * @return y
     */
    public int getY() {
        return y;
    }

    /**
     * 设置
     * @param y
     */
    public void setY(int y) {
        this.y = y;
    }

    /**
     * 获取
     * @return z
     */
    public String getZ() {
        return z;
    }

    /**
     * 设置
     * @param z
     */
    public void setZ(String z) {
        this.z = z;
    }

    public String toString() {
        return "test{x = " + x + ", y = " + y + ", z = " + z + "}";
    }

    @Override
    public int compareTo(test o) {
        return this.x - o.x; // 是按照x进行比较的 这个是从小到大的
    }
}
